package com.nf.health.app.widget;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.activity.global.MainActivity;
import com.nf.health.app.utils.ScreentUtils;
import com.nf.health.app.utils.TextUtilTools;


/**
 * Created by changpeng on 2017/06/02.
 * @author changpeng
 * @Description 课题报名成功Dialog
 *
 */
public class KetiSignUpSuccessDialog extends Dialog implements View.OnClickListener{

    private Context ctx;
    private View mContent;
    private TextView mTvDesc;
    private Button mBtnKnow;
    public KetiSignUpSuccessDialog(Context context) {
        //设置style
        super(context, R.style.dialog3);
        this.ctx = context;
        init();
    }

    //设置布局
    private void init() {
        setContentView(R.layout.keti_sign_up_success_dialog);
        mContent = findViewById(R.id.ll_content);
        mTvDesc = (TextView) findViewById(R.id.tv_desc);
        mBtnKnow = (Button) findViewById(R.id.btn_know);
        mBtnKnow.setOnClickListener(this);

        String htmlText = "<font color='#000000'><big>报名成功</big></font><br><br><font color='#BFBFBF'><small>请关注爱尚康APP<br>为您推荐的检测计划和健康管理方案</small></font>";
        TextUtilTools.setTextFromHtml(mTvDesc,htmlText);

        //设置大小
        FrameLayout.LayoutParams p = (FrameLayout.LayoutParams) mContent.getLayoutParams();
        p.width = (int) (ScreentUtils.getScreenWidth(ctx) * .8); //宽度占屏幕宽度的80%
        mContent.setLayoutParams(p);
    }

    @Override
    protected void onStart() {
        super.onStart();
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){

            case R.id.btn_know:
                dismiss();
                ctx.startActivity(new Intent(ctx, MainActivity.class));
                break;
        }
    }
}
